import time
from multiprocessing import Pool
import os


def f(i):
    time.sleep(1)
    # 打印进程号
    print('子进程：', os.getpid())
    return i + 100


def g(n):
    # 主进程来处理的
    print(n)
    print('回调函数进程：', os.getpid())


def main():
    print('主进程：', os.getpid())
    pool = Pool(processes=3)
    for i in range(5):
        pool.apply_async(func=f, args=(i,), callback=g)
    pool.close()
    pool.join()

if __name__ == '__main__':
    main()
